//
//  DHDoctorResumeViewController.m
//  DHKuaiYi
//
//  Created by  chenhanmao on 2016/11/16.
//  Copyright © 2016年 30-陈辉华. All rights reserved.
//

#import "DHDoctorResumeViewController.h"
#import "NetworkTool.h"
#import <Masonry.h>

@interface DHDoctorResumeViewController ()

/**  医生简介  */
@property(nonatomic,weak) UILabel *introductionLabel;

@end

@implementation DHDoctorResumeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self requestWithParameters:@{@"doctor_id":@300000315}];
}

- (void)xhhSetupSubviews {
    
    UILabel *introductionLabel = [[UILabel alloc] init];
    
    self.introductionLabel = introductionLabel;
    
    introductionLabel.numberOfLines = 0;
    
    [self.view addSubview:introductionLabel];
    
    /*------------------自动布局------------------*/
    CGFloat space = 16;
    [introductionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.equalTo(self.view).offset(space);
        make.right.equalTo(self.view).offset(-space);
    }];
}

/**
 网络请求
 */
-(void)requestWithParameters:(NSDictionary *)parameters {
    
    NSString *URLString = @"http://iosapi.itcast.cn/doctor/getIntroduction.json.php";
//    @{@"doctor_id":@300000315}
    
    [[NetworkTool sharedTool] POSTWithURLStr:URLString parameters:parameters success:^(id responseObject) {
        if (responseObject != nil) {

            NSString *introduction = responseObject[@"data"][@"introduction"];
            
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                
                self.introductionLabel.text = introduction;
                [self.introductionLabel sizeToFit];
            }];
        }
    } failed:^(NSError *error) {

        NSLog(@"%@",error);
        
    }];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
